package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;


    /**
     * 查询所有目的地
     * @return
     */
    @GetMapping("/list")
    public Object list(){

        return JsonResult.success(destinationService.list());
    }

    /**
     * 查询热门区域下的目的地
     * @param regionId
     * @return
     */
    @GetMapping("/search")
    public Object search(String regionId){

        List<Destination> list=  destinationService.searchDestination(regionId);

        return JsonResult.success(list);
    }

    /**
     * 查询热门区域
     * @return
     */
    @GetMapping("/hotRegion")
    public Object getHotRegion(){

        List<Region> regions = regionService.getHotRegion();

        return JsonResult.success(regions);
    }

    /**
     * 查询导航吐司
     * @return
     */
    @GetMapping("/toasts")
    public Object getToasts(String destId){

        List<Destination> toasts = destinationService.checkParent(destId);

        return JsonResult.success(toasts);
    }

    /**
     * 查询概述下分类和攻略
     * @return
     */
    @GetMapping("/catalogs")
    public Object getCatalogs(String destId){

        List<StrategyCatalog> catalogs = strategyCatalogService.queryStrategyCatalogs(destId);

        return JsonResult.success(catalogs);
    }

    /**
     * 查询目的地下的前3攻略
     * @return
     */
    @GetMapping("/strategies/viewnumTop3")
    public Object getStrategies(String destId){

        List<Strategy> strategies = strategyService.queryStrategies(destId);

        return JsonResult.success(strategies);
    }


    /**
     * 查询目的地下阅读数前三的游记
     * @param destId
     * @return
     */
    @GetMapping("/travels/viewnumTop3")
    public Object getTravels(String destId){

        List<Travel> travels = travelService.queryTravelsTop3(destId);

        return JsonResult.success(travels);
    }
}
